import { Body, Controller, Get, Inject, Post } from '@nestjs/common';
import { PoemService } from './poem.service';
import { CreateDto } from './dto/create.dto';
import { FindDto } from './dto/find.dto';
import { UpdateDto } from './dto/update.dto';
import { ListDto } from './dto/list.dto';
import { Public } from 'src/common/decorators/public.decorator';

@Controller('poem')
export default class PoemController {
  @Inject(PoemService)
  private readonly poemService: PoemService;

  @Post('create')
  create(@Body() body: CreateDto) {
    return this.poemService.create(body);
  }

  @Post('update')
  update(@Body() body: UpdateDto) {
    return this.poemService.update(body);
  }

  @Post('delete')
  delete(@Body() body: UpdateDto) {
    return this.poemService.delete(body);
  }

  @Post('find')
  find(@Body() body: FindDto) {
    return this.poemService.find(body);
  }

  @Post('list')
  @Public()
  list(@Body() body: ListDto) {
    return this.poemService.list(body);
  }

  @Get('crawl')
  crawl() {
    return this.poemService.crawl();
  }

  @Get('crawl-content')
  crawlContent() {
    return this.poemService.crawlContent();
  }
}
